import React from "react"
import { inject, observer } from 'mobx-react'
@inject('store')
@observer
class out extends React.Component {
  constructor(props) {
    super(props)
  }
  componentDidUpdate() {
    if(!this.props.store.user.getUser.data.name && this.props.history.location.pathname != '/login'){
      this.props.history.replace('/login')
    }
  }
 
  componentWillMount() {
    this.checkLogin()
 

  }
  render() {
    return (
      <div></div>
    )
  }
  checkLogin = () => {
    if (!this.props.store.user.getUser.data.name) {
      if (this.props.history.location.pathname != '/login') {
        this.props.history.replace('/login')
      }
    } else {
      this.props.history.replace('/')
    }
  }
}

export default out